#include <iostream>
using namespace std;

class Bed {
	protected:
		int weight;
		
	public:
		Bed(int w=0): weight(w) {}
		~Bed() {}
		Bed(const Bed & old) {
			weight = old.weight;
		}

		void Sleep() {
			cout << "Sleeping ..." << endl;
		}

		void SetWeight(int w) {
			weight = w;	
		}
};

class Sofa {
	protected:
		int weight;

	public:
		Sofa(int w=0): weight(w) {}
		~Sofa() {}
		Sofa(const Sofa & old) {
			weight = old.weight;
		}

		void WatchTV() {
			cout << "Watching TV ..." << endl;
		}

		void SetWeight(int w) {
			weight = w;
		}
};

class SleepSofa: public Bed, public Sofa {
	protected:
		int fold;

	public:
		SleepSofa(int w=0): Bed(w), Sofa(w) { fold = 1; }; // 沙发开始是折叠的
		~SleepSofa() {}

		void Foldout();
		int SetFold(int f) { fold = f; return 1; }
		void SetWeight(int w);
};

void SleepSofa::Foldout() {
	if(fold != 0)
		cout << "Fold out the sofa." << endl;
	else
		cout << "Not fold.It's a bed." << endl;
}

void SleepSofa::SetWeight(int w) {
	Bed::SetWeight(w);
	Sofa::SetWeight(w);
}

int main(void) {
	int w;
	cout << "Please input the weight of the SleepSofa: ";
	cin >> w;
	SleepSofa ss(w);

	ss.WatchTV();
	ss.Foldout();
	ss.Sleep();

	return 0;
}
